<cfcomponent output="false">
	
	<!--- --->

	<cffunction name="getImportant" access="public" output="true" returntype="query">
		<cfargument name="userID" required="false" default="#request.session.user.id#" />
		<cfargument name="expired" required="false" default="false" />
		<cfargument name="active" required="false" default="1" />
		<cfargument name="modified_after" required="false" default="" />

		<cfset var local = {} />

		<cfquery name="local.getImportant" datasource="#$.site.getVar('datasource')#">
			select 
			hex(important.id) as id,
			important.week,
			important.sort_order,
			important.name,
			important.complete,
			date_format(important.completed_on,'%m/%d/%Y') as completed_on,
			date_format(important.modified,'%m/%d/%Y %H:%i:%s') as modified,
			date_format(important.expiration_date,'%m/%d/%Y %H:%i:%s') as expiration_date,
			important.active
			from important
			where 1=1 
			<cfif arguments.active neq "">
				and important.active = #$.database.string(arguments.active)#
			</cfif>
			<cfif arguments.expired eq false>
				and expiration_date >= now()
			<cfelse>
				and expiration_date < now()
			</cfif>
			and important.created > #$.database.datetime('#year(now())#-01-01')#
			and important.user_id = #$.database.uuid(arguments.userID)#
			<cfif arguments.modified_after neq "">
				and important.modified >= #$.database.datetime(arguments.modified_after)#
			</cfif>
			order by important.sort_order asc
		</cfquery>
		
		<cfreturn local.getImportant />
		
	</cffunction>
	
	<!--- --->
	
	<cffunction name="getImportant_OLD" access="public" output="true" returntype="query">
		<cfargument name="week" required="true" />
		<cfargument name="week2" required="false" default="" />
		<cfargument name="userID" required="false" default="#request.session.user.id#" />

		<cfset var local = {} />

		<cfquery name="local.getImportant" datasource="#$.site.getVar('datasource')#">
			select 
			hex(important.id) as id,
			important.week,
			important.sort_order,
			important.name,
			important.complete,
			date_format(important.completed_on,'%m/%d/%Y') as completed_on,
			date_format(important.modified,'%m/%d/%Y %H:%i:%s') as modified,
			date_format(important.expiration_date,'%m/%d/%Y %H:%i:%s') as expiration_date
			from important
			where important.active = 1
			and (important.week = #$.database.int(arguments.week)#
				<cfif arguments.week2 neq "">
					or important.week = #$.database.int(arguments.week2)#
				</cfif>
			)
			and important.created > #$.database.datetime('#year(now())#-01-01')#
			and important.user_id = #$.database.uuid(arguments.userID)#
			and important.expiration_date is null
			order by important.sort_order asc
		</cfquery>
		
		<cfreturn local.getImportant />
		
	</cffunction>
	
	<!--- --->

</cfcomponent>